package com.lovo.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.lovo.bean.Savemoney;
import com.lovo.service.ISavemoneyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lovo
 * @since 2022-09-17
 */
@RestController
@RequestMapping("qd/savemoney")
public class SavemoneyController {

    @Autowired
    ISavemoneyService savemoneyService;

    @GetMapping("findSaveMoneyInfoByUserId/{PageNO}/{userId}")
    public IPage<Savemoney> findSaveMoneyInfoByUserId(@PathVariable("PageNO")Integer PageNO,
                                                      @PathVariable("userId")Integer userId){
        return savemoneyService.findSaveMoneyInfoByUserId(PageNO, userId);
    }


    @PutMapping("updateUserSaveMoneyByUserId/{userId}/{money}/{status}")
    public String updateUserSaveMoneyByUserId(@PathVariable("userId")Integer userId,
                                              @PathVariable("money")Integer money,
                                              @PathVariable("status")String status){
        boolean flag = savemoneyService.updateUserSaveMoneyByUserId(userId, money, status);
        if (flag){
            return "ok";
        }
        else {
            return "no";
        }
    }

}
